#ifndef UTIL_H
#define UTIL_H

#include <unistd.h>
#include <vector>

int Open(const char* filename, int flags);
void Close(int fd);
int Pipe(int fd[]);

int err_sys(const char* msg);

/**
 * Using `pgrep name` to find the process id.
 */
std::vector<int> find_process_id(const char* name);

inline int file_exists(const char* path) {
    return access(path, F_OK) != -1;
}

#endif /* UTIL_H */
